package com.quanshu.shop.goods.view;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.config.Config;
import com.quanshu.exchange.ui.base.BaseFragment;
import com.quanshu.shop.goods.custom.PreViewGSYVideoPlayer;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;


/**
 * A simple {@link Fragment} subclass.
 * Use the {@link GoodsVideoFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class GoodsVideoFragment extends BaseFragment {


    @BindView(R.id.goods_video_player)
    PreViewGSYVideoPlayer goodsVideoPlayer;
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private String Url = "";

    Unbinder unbinder;
    private OrientationUtils orientationUtils;

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;


    public GoodsVideoFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @return A new instance of fragment GoodsVideoFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static GoodsVideoFragment newInstance(String url) {
        GoodsVideoFragment fragment = new GoodsVideoFragment();
        fragment.Url = url;
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int setFragmentLayoutID() {
        return R.layout.fragment_goods_video;
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
//        String source1 = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
        String source1 = Config.URL_HOST_SHOP_IMG + Url;
        Log.d("视频URL", "initView: " + source1);
        goodsVideoPlayer.setUp(source1, true, "测试商品");
        goodsVideoPlayer.getTitleTextView().setVisibility(View.GONE);
        goodsVideoPlayer.getBackButton().setVisibility(View.GONE);
        //goodsVideoPlayer.startPlayLogic();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
